
<script>

$("#changeUserPwA_Z").bind("click", function(){
	$("#changeUserPwDIV_Z input[type='password']").val("");
	$("#changeUserPwDIV_Z").show("slow");
	$("#changeUserPwA_Z").hide("slow");
	$("#formOptDIV_Z").hide("slow");
	
});

$("#submitPwBtn").bind("click", function(){
	var msgDIV = $("#messageDIV");
	var flag = false;
	var curpw = $("#curpw").val();
	curpw = $.trim(curpw);
	if(curpw == ""){
		MZMsg.showMsg(msgDIV, "请输入您当前使用的密码!", "warning");
		return false;
	}
	$.ajax({
		url: "checkCurPw", 
		type: "post",
		async: false,
		data: {"curpw":curpw},
		success: function(result){
			flag = result;
		},
		error: function(result){
			MZ.showMsg(result);
		}
	});
	if(!flag){
		MZMsg.showMsg(msgDIV, "当前密码不正确!", "warning");
		return false;
	}
	var password = $("#newpw").val();
	password = $.trim(password);
	var passwordConfirm = $("#newpwConfirm").val();
	passwordConfirm = $.trim(passwordConfirm);
	if(password==""){
		MZMsg.showMsg(msgDIV, "新密码不能为空!", "error");
		return false;
	}else if(password.length<6){
		MZMsg.showMsg(msgDIV, "密码过短(6-16长度)!", "error");
		return false;
	}else if(password!=$.trim(passwordConfirm)){
		MZMsg.showMsg(msgDIV, "两次密码不一致!", "error");
		return false;
	}else if(password==curpw){
		MZMsg.showMsg(msgDIV, "密码没有发生改变!", "warning");
		return false;
	}
	
	var newpw = $("#newpw").val();
	var params = {"newpw": newpw};
	$.ajax({
		url : "updatePw",
		// processData: false,
		type : "post",
		data : params,
		beforeSend : function() {
		},
		success : function(result) {
			if(result.succeed){
				MZMsg.showMsg(msgDIV, result.message, "success");
			}else{
				MZMsg.showMsg(msgDIV, result.message, "error");
			}
		},
		error: function(result){
			MZMsg.showMsg(msgDIV, result, "error");
		}
	});
	$("#changeUserPwA_Z").show("slow");
	$("#formOptDIV_Z").show("slow");
	$("#changeUserPwDIV_Z").hide("slow");
});
$("#resetPwBtn").bind("click", function(){
	$("#changeUserPwA_Z").show("slow");
	$("#formOptDIV_Z").show("slow");
	$("#changeUserPwDIV_Z").hide("slow");
});
$("#messageDIV").bind("click", function(){
	$(this).hide("slow");
});
$("#resetBtn").bind("click", function(){
	$("#userInfoForm_F input[type='text'][readonly!='readonly']").val("");
	$("#description").val("");
});
$("#submitBtn").bind("click", function(){
	var msgDIV = $("#messageDIV");
	var params = $('#userInfoForm_F').serializeObject();
	params = {"nickname":params.nickname,"phone":params.phone,
			  "email":params.email,"description":params.description}
	if($.trim(params.nickname)==""){
		MZMsg.showMsg(msgDIV, "姓名不能为空!", "warning");
		return false;
	}else if($.trim(params.phone)!=""){
		reg=/^[0-9\-\+\(\)]*$/;
		if(!reg.test(params.phone)){
			MZMsg.showMsg(msgDIV, "请输入正确的联系号码!", "warning");
			return false;
		}
	}else if($.trim(params.email)!=""){
		reg=/^[a-zA-Z0-9]([a-zA-Z0-9]*[-_.]?[a-zA-Z0-9]+)+@([\w-]+\.)+[a-zA-Z]{2,}$/;
		if(!reg.test(params.email)){
			MZMsg.showMsg(msgDIV, "请输入正确的邮箱地址!", "warning");
			return false;
		}
	}
	params = $.toJSON(params);
	$.ajax({
		url : "updateUser",
		// processData: false,
		type : "post",
		data : "data="+params,
		beforeSend : function() {
		},
		success : function(result) {
			if(result.succeed){
				MZMsg.showMsg(msgDIV, result.message, "success");
			}else{
				MZMsg.showMsg(msgDIV, result.message, "error");
			}
		},
		error: function(result){
			MZMsg.showMsg(msgDIV, result, "success");
		}
	});
});


var MizoMsg=function(){
	var showCount = 0;

	this.showMsg=function(msgDIV, msgContent, type){
		showCount++;
		msgDIV.html("<span class=\"message "+type+"\"><strong>"+type+" </strong>"+msgContent+"!</span>");
		msgDIV.show("slow");
		this.msgDIV = msgDIV;
		var showTime = 3000;
		if(showCount!=1){
			showTime = 6000;
		}
		setTimeout("MZMsg.hideMsg()",showTime);
	};
	
	this.hideMsg=function(){
		showCount--;
		this.msgDIV.hide("slow");
	}
};
var MZMsg=new MizoMsg();

</script>

<div style="display: ;">
		<h2 class="box-header">${user.username}</h2>
		<div align="left" id="userInfoDIV" class="box-content" style="width:600px;height:500px;overflow:auto;">
			
			<form id="userInfoForm_F" method="post">
			<label class="form-label required"> 用户姓名 </label>
			<input id="nickname" class="form-field width60" name="nickname" type="text" value="${user.nickname}" maxlength="100"/>
			
			<label id="" class="form-label">
			<input id="changeUserPwA_Z" class="button themed" type="button" value="修改密码" name="signup" />
			</label>
			<label class="form-label">&nbsp;</label>
			<div id="messageDIV" style="display: none">
				
			</div>
			<fieldset id="changeUserPwDIV_Z" style="background:#00000;display: none">
			<div class="width60" style="display: ;">
				<label class="form-label required"> 当前密码</label>
				<input id="curpw" class="form-field width60" name="curpw" type="password" value="" maxlength="100"/>
				<label class="form-label required"> 新密码</label>
				<input id="newpw" class="form-field width60" name="newpw" type="password" value="" maxlength="100"/>
				<label class="form-label"> 确认密码 </label>
		 		<input id="newpwConfirm" class="form-field width60" name="newpwConfirm" type="password" value="" maxlength="100"/>
		 		<br/>
	 			<input id="resetPwBtn" class="button red" type="button" value="取消" name="reset" />
				<input id="submitPwBtn" class="button themed" type="button" value="修改密码" name="signup" />
			</div>
			</fieldset>
			
			<label class="form-label"> 部门 </label>
			<input id="deptName" readonly="readonly" class="form-field width60" name="deptName" type="text" value="${user.deptName}" maxlength="100"/>
			
			<label class="form-label"> 角色 </label>
			<input id="roleName" readonly="readonly" class="form-field width60" name="roleName" type="text" value="${user.roleNames}" maxlength="100"/>
			
			<label class="form-label"> 电话 </label>
		 	<input id="phone" class="form-field width60" name="phone" type="text" value="${user.phone}" maxlength="100"/>
			
			<label class="form-label"> 邮箱 </label>
			<input id="email" class="form-field width60" name="email" type="text" value="${user.email}" maxlength="100"/>
			
			<label class="form-label"> 备注 </label>
			<textarea id="description" class="form-field width90" style="height:40px" name="description" cols="" rows="4">${user.description}</textarea>
			
			<div id="formOptDIV_Z">			
			<input id="resetBtn" class="button red" type="button" value="重置" name="resetBtn" />
			<input id="submitBtn" class="button themed" type="button" value="确认修改" name="submitBtn" />
			</div>
		</form>
		</div>
		
</div>
